package com.yf.stat.modules.total.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.yf.base.utils.DateUtils;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
* <p>
* 考试统计数据传输类
* </p>
*
* @author 聪明笨狗
* @since 2021-06-04 09:08
*/
@Data
@ApiModel(value="考试统计", description="考试统计")
public class StatTotalExamDTO implements Serializable {

    private static final long serialVersionUID = 1L;


    @ApiModelProperty(value = "ID", required=true)
    private String id;

    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @ApiModelProperty(value = "统计时间")
    private Date statDate;

    @ApiModelProperty(value = "考试ID")
    private String examId;

    @ApiModelProperty(value = "考试人数")
    private Integer examUser;

    @ApiModelProperty(value = "通过用户")
    private Integer passUser;

    @ApiModelProperty(value = "考试次数")
    private Integer examCount;

    /**
     * 月份格式化
     * @return
     */
    public String getDateStr(){
        return DateUtils.formatDate(statDate, "MM/dd");
    }

    /**
     * 月份格式化
     * @return
     */
    public String getPassRate(){
        if(examUser ==0 || passUser==0){
            return "0";
        }

        float rate = passUser*100 / examUser;
        return String.format("%.2f", rate);
    }


}
